/*
 * @Author: Leo.wang wanglizhigs@163.com
 * @Date: 2025-09-05 20:35:41
 * @LastEditors: Leo.wang wanglizhigs@163.com
 * @LastEditTime: 2025-09-05 20:58:23
 * @FilePath: /medical-companion-manage/src/utils/convention.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { CamelToSnake, SnakeToCamel } from '@multi-kit/convention';
import { isObject, isArray } from '@multi-kit/inspect';

export function formatObjectKeys(target, converter, depth = 1) {
  if (!isObject(target)) {
    return target
  }
  let iDepth = 0
  function recursion(target) {
    // if (iDepth >= depth) {
    //   return target
    // }
    // iDepth += 1
    const result = Object.entries(target).reduce((acc, [key, value]) => {
      if (isObject(value)) {
        acc[converter(key)] = recursion(value)
      } else if (isArray(value)) {
        acc[converter(key)] = value.map(recursion)
      } else {
        acc[converter(key)] = value
      }
      return acc
    }, {})

    return result;
  }


  return recursion(target)
}